#!/usr/bin/perl -w
use strict;
use warnings;

my $bin_value = binomial(4, 2, 0.03);
my $score;
$score = -10*(log($bin_value)/log(10));
#
print $bin_value, "\n";
print $score;

sub binomial{
	#Binomial distribution
	use Math::NumberCruncher;
	#($n,$k,$p)->$k successes in $n tries, given a probability of $p	
	my $n=$_[0];
	my $k=$_[1];
	my $p=$_[2];
	my $binomial_acumulada=0;
	for(my $i=$k; $i<$n+1;$i++){
		my $binomial=Math::NumberCruncher::Binomial($n,$i,$p);
		$binomial_acumulada= $binomial_acumulada+$binomial;
	}
	return $binomial_acumulada;
}
